﻿#ifndef STUINFOMNTWIGET_H
#define STUINFOMNTWIGET_H

#include <QWidget>
#include <QGuiApplication>
#include <QScreen>
#include <QStandardItemModel>
#include <QStandardItem>
#include "CDataMySQL.h"
#include "dialAddStuInfo.h"
#include <QMenu>

namespace Ui {
class StuInfoMntWiget;
}

class StuInfoMntWiget : public QWidget
{
    Q_OBJECT

public:
    explicit StuInfoMntWiget(QWidget *parent = nullptr);
    ~StuInfoMntWiget();
    // --------------------------------------------------------------------------------- 学生信息 表结构改变 需改的代码
    const int CONST_TABLE_COLSIZE = 4;

    const int CONST_ID_COL = 0;
    const int CONST_NAME_COL = 1;
    const int CONST_GENDER_COL = 2;
    const int CONST_POLID_COL = 3;
    const int CONST_PHONUM_COL = 4;
    const int CONST_ADDRESS_COL = 5;
    const int CONST_GPA_COL = 6;

    void initUI();

    bool addToTableView(CStuInfo &stuInfo);

signals:
    void backToLog();

public slots:
    void on_btnBack2Log_clicked();

    void slot_addInfo(CStuInfo &stuInfo);   // sig_addInfo(CStuInfo &stuInfo) 会自动传递参数过来

    void slot_modInfo(CStuInfo &stuInfo);

    bool slot_itemChecked(QStandardItem *item);

    bool slot_popMenu(const QPoint &pos);

    bool slot_actUpdate();

    bool slot_actDelete();

private slots:
    void on_btnAddData_clicked();

    void on_chkBox_selectAll_clicked(bool checked);

    void on_btnDelData_clicked();

private:
    Ui::StuInfoMntWiget *sim_ui;
    CDataMySQL *dataSource;             // 数据源
    QStandardItemModel *dataItemModel;  // UI 一条记录

    DialAddStuInfo *addStuWin;          // 添加信息
    QMenu * menu;                       // 右键 弹出菜单
    QAction *actUpdate;                 // 菜单项：修改学生信息
    QAction *actDelete;                 // 菜单项：删除学生信息

    int ordId;                          // 用于修改学生信息
};

#endif // STUINFOMNTWIGET_H
